package com.wu.shop.wxapi

import android.content.Context
import com.tencent.mm.opensdk.modelpay.PayReq
import com.tencent.mm.opensdk.openapi.WXAPIFactory
import com.wu.shop.BuildConfig

/**
 * 微信支付的工具类
 */

object WechatUtil {
    /**
     * 支付
     */
    fun payWechat(
        mContext: Context,
        partnerId: String,
        prepayId: String,
        nonceStr: String,
        timeStamp: String,
        sign: String
    ) {
        var api = WXAPIFactory.createWXAPI(mContext, BuildConfig.APP_WECHAT_KEY);
        api.registerApp(BuildConfig.APP_WECHAT_KEY)

        var req = PayReq()
        req.appId = BuildConfig.APP_WECHAT_KEY
        req.partnerId = partnerId
        req.prepayId = prepayId
        req.nonceStr = nonceStr
        req.timeStamp = timeStamp
        req.packageValue = "Sign=WXPay"
        req.sign = sign
        req.extData = ""
        api.sendReq(req)
    }
}